package com.es.core.utils;


import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @todo
 * @createdBy zhanglj
 * @Date 2015/12/3.
 */
public class ObjectMappingCustomer extends ObjectMapper {
    public ObjectMappingCustomer(){
        super();
        //空值处理为空串
        getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
            @Override
            public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
                gen.writeString("");
            }

        });
    }
}
